//Controller που ελεγχει την καταχωρηση του καταστηματος
package Controllers;

import DAO.StoreEntry_Dao;
import Exceptions.DaoException;

public class StoreEntry_Controller {

    public StoreEntry_Controller() {

    }

    public StoreEntry_Controller(StoreEntry_Dao storeEntry_Dao) {

    }

    public boolean validateStorentry(String StoreName, String Address, String City, String StorePhone, String Floors, String Seats, String Parking, String ParkingSpots, String DaysOpen) throws IllegalArgumentException, DaoException {
        boolean x;
        try {
            if (StoreName.isEmpty() || Address.isEmpty() || StorePhone.isEmpty() || Floors.isEmpty() || City.isEmpty() || ParkingSpots.isEmpty() || DaysOpen.isEmpty() || Parking.isEmpty() || Seats.isEmpty()) {
                x = false;
            } else if (StorePhone.length() > 10 || StorePhone.length() < 10) {
                x = false;
            } else if (StorePhone.matches("[0-9]+") == false) {
                x = false;
            } else if (Floors.matches("[0-9]+") == false) {
                x = false;
            } else if (Seats.startsWith("0") && Seats.endsWith("0")) {
                x = false;
            } else if (Seats.matches("[0-9]+") == false) {
                x = false;
            } else if (ParkingSpots.matches("[0-9]+") == false) {
                x = false;
            } else if (StoreName.length() > 25) {
                x = false;
            } else {
                DAO.StoreEntry_Dao y = new DAO.StoreEntry_Dao();
                y.validateStoreEntry(StoreName, Address, City, StorePhone, Floors, Seats, Parking, ParkingSpots, DaysOpen);
                x = true;
            }
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Error in StoreEntry_Controller");
        }
        return x;
    }
}
